package com.yang.wemedia;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.yang.common.config.MyMetaObjectHandler;
import com.yang.common.context.SpringContextUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @author Billyang
 * @date 2024/9/24 10:45
 */
@SpringBootApplication(scanBasePackages = "com.yang")
@MapperScan("com.yang.wemedia.mapper")
@EnableFeignClients(basePackages = "com.yang.apis")
@EnableAsync
@EnableScheduling
public class WeMediaApplication {

    public static void main(String[] args) {
        SpringApplication.run(WeMediaApplication.class, args);
        MyMetaObjectHandler bean = SpringContextUtil.getBean(MyMetaObjectHandler.class);
        System.out.println("mybatis meta:"+bean);

    }

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
